<?php
require_once SITE_PATH . '/apps/group/Common/common.php';
class GroupSquareModel extends Model {
	public function square()
	{
		// 热门群组排行
		$data['hot_group_list']  = D('Group', 'group')->getHotList();
		// 热门群标签
		$data['hot_tags_list']   = D('GroupTag', 'group')->getHotTags();
		// 群组热帖
		$data['hot_thread_list'] = D('Topic', 'group')
		                           ->field('id,gid,title,dist,attach')
                                   ->where('is_del=0 AND replytime>' . (time()-30*24*3600))
		                           ->order('viewcount+replycount DESC,id DESC')
                                   ->limit(10)->findAll();
        // 群组分类
        $data['category_tree']   = D('Category', 'group')->_makeTree(0);
        foreach ($data['category_tree'] as $k => $v) {
            $data['category_tree'][$k]['count'] = D('Group', 'group')->where("cid0={$v['a']} AND is_del=0")->count();
        }
        // 热门标签推荐
        $data['reTags']  = D('GroupTag', 'group')->getHotTags('recommend');

		return $data;
	}
}